import 'package:factoryside/utils/utils.dart';
import 'package:factoryside/webview/page_web.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';

class AboutMePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _AboutMePage();
  }
}

class _AboutMePage extends State<AboutMePage> {
  PackageInfo packageInfo;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
     PackageInfo.fromPlatform().then((value) => this.setState(() {
       packageInfo=value;
       String appName = packageInfo.appName;
       String packageName = packageInfo.packageName;
       String version = packageInfo.version;
       String buildNumber = packageInfo.buildNumber;
       print('appName:$appName,packageName:$packageName,version:$version,buildNumber:$buildNumber');
     }));
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: buildAppBar('关于我们',null,context),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Container(
              color: Color.fromARGB(255, 240, 240, 240),
              alignment: Alignment.center,
              height: 100,
              child: Image.asset("assets/app.png",
                  width: 50, height: 50),
            ),

            /*版本号*/
            Container(
              height: 58,
              decoration: BoxDecoration(
                  border: Border(
                      top: BorderSide(color: Colors.grey, width: 0.2),
                      bottom: BorderSide(color: Colors.grey, width: 0.2))),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Text("当前版本"),
                  ),
                  Expanded(
                      child: Container(
                    margin: EdgeInsets.only(right: 10),
                    alignment: Alignment.centerRight,
                    child: Text(packageInfo==null?'':'v${packageInfo.version}'),
                  ))
                ],
              ),
            ),

            /*官网地址*/
            Container(
              height: 58,
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Colors.grey, width: 0.2))),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Text("官方网站"),
                  ),
                  Expanded(
                      child: Container(
                    margin: EdgeInsets.only(right: 10),
                    alignment: Alignment.centerRight,
                    child: Text("www.xigyu.com",
                        style: TextStyle(
                            color: Colors.blue)),
                  ))
                ],
              ),
            ),
            /*联系我们*/
            Container(
              height: 58,
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Colors.grey, width: 0.2))),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Text("联系我们"),
                  ),
                  Expanded(
                      child: Container(
                    margin: EdgeInsets.only(right: 10),
                    alignment: Alignment.centerRight,
                    child: Text("400-6262-365"),
                  ))
                ],
              ),
            ),

            /*用户协议*/
            GestureDetector(
              child: Container(
                height: 58,
                decoration: BoxDecoration(
                    border: Border(
                        bottom: BorderSide(color: Colors.grey, width: 0.2))),
                child: Row(
                  children: <Widget>[
                    Expanded(
                      child: Padding(
                        padding: EdgeInsets.only(left: 10),
                        child: Text("用户协议"),
                      ),
                    ),
                    Image.asset(
                        'assets/right.png',
                        width: 15,
                        height: 15,
                      )
                  ],
                ),
              ),
              onTap: () {
                push(context, WebPage('服务协议', 'https://admin.xigyu.com/Message/service', null));
              },
            ),

            /*版权所有*/
            Container(
              height: 58,
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Colors.grey, width: 0.2))),
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Text("版权所有"),
                  ),
                  Expanded(
                      child: Container(
                    margin: EdgeInsets.only(right: 10),
                    alignment: Alignment.centerRight,
                    child: Text("宁波正海科技有限公司"),
                  ))
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
